package com.example.emos.api.service.impl;

import com.example.emos.api.common.util.PageUtils;
import com.example.emos.api.db.dao.TbHardwareDao;
import com.example.emos.api.db.pojo.TbHardware;
import com.example.emos.api.service.HardwareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
@Service
public class HardwareServiceImpl implements HardwareService {
    @Autowired
    private TbHardwareDao hardwareDao;
    @Override
    public ArrayList<HashMap> searchAllHardware() {
        ArrayList<HashMap> list = hardwareDao.searchAllHardware();
        return list;
    }

    @Override
    public int addHardware(HashMap hashMap) {

        return hardwareDao.addHardware(hashMap);
    }

    @Override
    public int addHardwareMore(ArrayList<TbHardware> hashMaps) {
        return hardwareDao.addHardwareMore(hashMaps);
    }

    @Override
    public int updateHardware(HashMap hashMap) {
        return hardwareDao.updateHardware(hashMap);
    }

    @Override
    public int deleteByIds(Integer[] ids) {
        return hardwareDao.deleteByIds(ids);
    }

    @Override
    public PageUtils searchByModelAndStatus(HashMap hashMap) {

        ArrayList<HashMap> list= hardwareDao.searchByModelAndStatus(hashMap);
       long count= hardwareDao.searchHardCount(hashMap);
        int start=(Integer) hashMap.get("start");
        int length=(Integer) hashMap.get("length");
        PageUtils pageUtils=new PageUtils(list,count,start,length);
        return pageUtils;
    }

    @Override
    public long searchHardCount(HashMap hashMap) {
        return hardwareDao.searchHardCount(hashMap);
    }

    @Override
    public long searchHCount(HashMap hashMap) {
        return hardwareDao.searchHCount(hashMap);
    }


}
